import 'package:flutter/material.dart';

enum JsTextFont {
  PoetsenOne,
  Candal,
  EricaOne,
  October_Devanagari_Regular,
  October_Devanagari_Medium,
  RubikOne,
  Source_KeynoteartHans,
  DIN_Alternate,
  System_Medium,
}

TextStyle jsTextStyle({
  double? fontSize,
  Color? fontColor,
  required JsTextFont font,
  double height = 1.1,
  List<Shadow>? shadows,
  Paint? foreground,
  TextDecoration? decoration,
  Color? decorationColor,
  double? decorationThickness,
  double? letterSpacing,
}) {
  return TextStyle(
    fontSize: fontSize,
    color: fontColor,
    fontFamily: font == JsTextFont.System_Medium ? null : font.name,
    fontWeight: font == JsTextFont.System_Medium
        ? FontWeight.w500
        : font == JsTextFont.October_Devanagari_Regular
            ? FontWeight.w400
            : font == JsTextFont.October_Devanagari_Medium || font == JsTextFont.DIN_Alternate
                ? FontWeight.bold
                : null,
    height: height,
    shadows: shadows,
    foreground: foreground,
    decorationColor: decorationColor,
    decorationThickness: decorationThickness,
    decoration: decoration,
    letterSpacing: letterSpacing,
  );
}

Decoration jsShapeRound({
  required double radius,
  Color? color,
  double? borderWidth,
  Color? borderColor,
  List<BoxShadow>? shadows,
}) {
  final border = (borderColor == null || borderWidth == null || borderWidth <= 0) ? null : BorderSide(color: borderColor, width: borderWidth);

  return ShapeDecoration(
    color: color,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(radius)),
      side: border ?? BorderSide.none,
    ),
    shadows: shadows,
  );
}

Decoration jsShapeRoundT({
  required double radius,
  Color? color,
  double? borderWidth,
  Color? borderColor,
  List<BoxShadow>? shadows,
}) {
  final border = (borderColor == null || borderWidth == null || borderWidth <= 0) ? null : BorderSide(color: borderColor, width: borderWidth);

  return ShapeDecoration(
    color: color,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(top: Radius.circular(radius)),
      side: border ?? BorderSide.none,
    ),
    shadows: shadows,
  );
}

Decoration jsShapeGradientT2B({
  double? radius,
  double? borderWidth,
  Color? borderColor,
  required List<Color> colors,
  List<double>? stops,
  GradientTransform? transform,
  List<BoxShadow>? shadows,
}) {
  final gradient = LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: colors,
    stops: stops,
    transform: transform,
  );

  if (radius != null && radius > 0) {
    final border = (borderColor == null || borderWidth == null || borderWidth <= 0) ? null : BorderSide(color: borderColor, width: borderWidth);

    return ShapeDecoration(
      gradient: gradient,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(radius)),
        side: border ?? BorderSide.none,
      ),
      shadows: shadows,
    );
  }

  final border = (borderColor == null || borderWidth == null || borderWidth <= 0) ? null : Border.all(color: borderColor, width: borderWidth);

  return BoxDecoration(
    gradient: gradient,
    boxShadow: shadows,
    border: border,
  );
}
